#!/usr/bin/ruby

require 'thread'

class PlayerAI
	def initialize
		@q = SizedQueue.new(2)
	end

	def lot_jobs
		10.times {|i|@q.push i.to_s;puts("#{i} been pushed!")}
	end

	def k
		@t.kill
	end

	def do
		@t = Thread.new do
			loop do
				begin
					job = @q.pop(true)
					puts "get a job : #{job.chomp} , now do something...."
					sleep 3
				rescue =>e
					puts "#{e.message}"
					sleep 1
				end
			end
		end
	end

	def play
		loop do
			@q.push gets
		end
	end
end